#Requires AutoHotkey v2.0

runcmd(cmd){
    tempFile := A_Temp "\\ahk_cmd_" A_TickCount ".txt"
    RunWait('cmd /c ' cmd ' > "' tempFile '"', , "Hide")
    try {
        result := FileRead(tempFile)
        FileDelete(tempFile)
        return result
    } catch Error as e {
        return "读取结果文件时发生错误: " . e.Message
    }
}

g1:=Gui()
txt1:=g1.Add("Text","w400 h300", "")
g1.Show()

res:=runcmd("ipconfig")
txt1.Value:=res